package cn.zymall.merchant.controller;

import cn.zymall.common.controller.crud.BaseController;
import cn.zymall.common.model.Coupon;
import cn.zymall.common.model.UserCoupon;
import cn.zymall.merchant.service.UserCouponService;
import cn.zymall.merchant.service.impl.UserCouponServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @ClassName UserCouponController
 * @Description TODO
 * @Author chenmei
 * @Date 2020/8/24 21:32
 * @Version 1.0
 **/
@RestController
@RequestMapping("/userCoupon")
public class UserCouponController extends BaseController<UserCouponService, UserCoupon> {
	@Autowired
	UserCouponServiceImpl userCouponService;

	@GetMapping("/getUserCouponByCouponId")
	public List<UserCoupon> getUserCouponByCouponId(Integer couponId){
		return userCouponService.getUserCouponByCouponId(couponId);
	};

	@PostMapping("/addUserCoupon")
	public Integer addUserCoupon(@RequestBody UserCoupon userCoupon){
		System.out.println(userCoupon+"///////////////");
		return userCouponService.addUserCoupon(userCoupon);
	}

	@GetMapping("/getUserCouponCount")
	public Integer getUserCouponCount( Integer couponId, Integer userId) {
		return userCouponService.getUserCouponCount(couponId,userId);
	}

	@GetMapping("/getUserCouponByUserId")
	public List<Coupon> getUserCouponByUserId(Integer userId) {
		return userCouponService.getUserCouponByUserId(userId);
	}
}
